
<template>
  <BaseModal
    :visible="visible"
    title="版本记录"
    :width="1200"
    destroy-on-close
    @cancel="handleModalCancel"
  >
    <s-table
      ref="table"
      row-key="id"
      :columns="columns1"
      :data="loadData"
      :alert="true"
      show-size-changer
      show-quick-jumper
      :show-pagination="false"
      :scroll="{ y: 400 }"
      bordered
    >
      <template
        slot="operation"
        slot-scope="text, record"
      >
        <a @click="handleDetail(record)">查看</a>
      </template>
    </s-table>
    <template slot="footer">
      <a-button @click="handleModalCancel">
        关闭
      </a-button>
    </template>
  </BaseModal>
</template>
<script>
import BaseModal from '@/components/BaseModal'
import { columns1,pageName} from '../model.js'
import { querySchemeVersionList } from '@/api/project/plannManagement/index.js' // api
export default {
  name: 'VersionRecord',
  props: {
    // 隐藏显示
    visible: {
      type: Boolean,
      require: true
    },
    // 版本记录信息
    data: {
      type: Object,
      require: true
    }
  },
  components: {
    BaseModal
  },
  data() {
    return {
      // 表头
      columns1,
    }
  },
  methods: {
    /**
     * @description: 表格数据加载方法
     * @param {Object} parameter 分页信息
     * @return {Promise} 接口Promise
     */
    async loadData(parameter) {
      try {
        const res = await querySchemeVersionList({ detailId: this.data.id })
         return {
                code: 200,
                ...res.data,
                data: res.data,
                 }
      } catch (error) {
        console.log(error)
        return Promise.reject()
      }
    },
    /**
     * @description: 查看详情
     * @param {object} record 行数据
     * @return {void}
     */
    handleDetail(record) {
      const { version } = record
      const { id, code } = this.data
      this.handleModalCancel()
      this.$router.push({
        path: '/project/plannManagement/plannTableComponents',
        query: {
          id,
          pageType: 'detail',
          editModel: 0,
          pageName: pageName[code - 26],
          version
        }
      })
    },
    /**
     * @description: 关闭模态框
     * @param {void}
     * @return {void}
     */
    handleModalCancel() {
      this.$emit('update:visible', false)
    }
  }
}
</script>
<style lang="less" scoped>
@deep: ~'>>>';
@{deep} .ant-table-fixed {
  margin-left: 0;
}
</style>
